﻿namespace EFMLEditor.Internal
{
    using System.Collections.Generic;
    using System.Windows.Forms;

    public class TreeProjectBuilder
    {
        public static TreeNode Build(string appname, Dictionary<string, string> windows, List<string> Strings)
        {
            var root = new TreeNode(appname) { ImageIndex = 0 };
            var props = new TreeNode("Properties");
            var strings = new TreeNode("Strings");

            props.ImageIndex = 4;
            props.SelectedImageIndex = 4;
            strings.ImageIndex = 5;
            strings.SelectedImageIndex = 5;

            foreach (var s in Strings)
            {
                var n = new TreeNode(s) { ImageIndex = 2 };
                n.SelectedImageIndex = 2;
                strings.Nodes.Add(n);
            }

            props.Nodes.Add(strings);
            root.Nodes.Add(props);
            
            foreach (var window in windows)
            {
                var defaultWindow = new TreeNode(window.Key);
                var code = new TreeNode(window.Value);
                code.ImageIndex = 3;
                code.SelectedImageIndex = 3;
                defaultWindow.Nodes.Add(code);
                defaultWindow.ImageIndex = 1;
                defaultWindow.SelectedImageIndex = 1;

                root.Nodes.Add(defaultWindow);
            }

            return root;
        }

    }
}
